// Copyright 2011 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.


/*
 * @fileoverview Template for Config model.
 *
 * @author jasonstredwick@google.com (Jason Stredwick)
 */


{namespace bite.layer.soy.Config}


/**
 * Returns a link tag for the view.
 * @param baseUrl Base url for relative links.
 */
{template .getView}
<link rel="stylesheet" type="text/css"
      href="
        {if $baseUrl}
          {$baseUrl}
        {/if}
        styles/config.css">
{/template}


/**
 * Defines the model for the config console that allows users to update and
 * add layers to the layer management server.
 */
{template .getModel}
<div id="layer-config-console" class="layer-console">
  <div class="layer-console-title">Layer Configuration</div>

  <div class="layer-console-body">
    <fieldset>
      <ol>
        <li>

          <table>
            <thead>
              <tr>
                <td></td>
                <td>Name</td>
                <td></td>
              </tr>
            </thead>
            <tbody id="layer-config-tbody">
            </tbody>
          </table>

        </li>
      </ol>
    </fieldset>
  </div>

  <div class="layer-console-footer">
    <button id="layer-config-create" type="button">Create Layer</button>
    <button id="layer-config-add" type="button">Add Layer Url</button>
    <button id="layer-config-close" class="layer-console-button-right"
            type="button">Close</button>
  </div>
</div>
{/template}


/**
 * Creates the innerHTML for a row in the layer configuration table.
 * @param url The url of the layer manifest.
 * @param? name The name of the layer.
 */
{template .createRow}
  <td>
    {if $name}
      <button id="layer-config-edit-{$name|id}" type="button">Edit</button>
    {else}
      <button disabled="true" type="button">Edit</button>
    {/if}
  </td>
  <td class="layer-config-name">
    {if $name}
      {$name}
    {else}
      {$url}
    {/if}
  </td>
  <td>
    {if $name}
      <button id="layer-config-remove-{$name|id}" type="button">
        Remove
      </button>
    {else}
      <button id="layer-config-remove" type="button">Remove</button>
    {/if}
  </td>
{/template}

